const express = require("express");
const { verifyToken, transferToken } = require("../utils/jwt");
const router = express.Router();
const imgController = require("../controller/imgController");
const { uploadImg } = require("../utils/upload");
const imgValidator = require("../middleware/validator/imgValidator");

router
  // 获取图片列表
  .get("/", (req, res) => {
    res.send("Img list");
  })
  // 上传图片
  .post(
    "/upload",
    verifyToken,
    uploadImg.single("file"),
    imgValidator.upload,
    imgValidator.validateImg,
    imgController.uploadImg
  )
  // 图片详情
  .get("/:id", transferToken, imgController.getImg);

module.exports = router;
